{extend name="./app/admin/view/main.html" /}
{block name="title"}{$indexTitle} - {__block__}{/block}
{block name="style"}
<style>
    
.user-statistical .nice-box-body {
}

.user-statistical .nice-iconfont {
    font-size: 35px;
    position: absolute;
    right: 0;
    bottom: 0px;
    color: #0AE;
    opacity: 0.2;
}

.user-statistical h3 {
    font-size: 20px;
    color: #0AE;
}

.user-statistical h3 .unit {
    display: none;
    color: #999;
    font-size: 12px;
}

.user-statistical p {
    color: #bababa;
    font-size: 14px;
}
.line {
    line-height: 30px;
}
.copyright-info p {
    line-height: 30px;
}
.nice-box .nice-box-heading .setting_bu{
	float:left;
	margin-right:30px;
	font-weight: 700;
    color: #72777d;
    line-height:30px;
}
.nice-box .nice-box-heading .active{
	color:#2796ea;
}

 .template-item {
        position: relative;
    }
.template-item img {
        /*width: 100%;
        height: auto;
        cursor: pointer;*/
        width: 90%;
	    height: auto;
	    cursor: pointer;
	    height: 78%;
	    margin: 50px 15px;
    }
.template-item .ivu-icon-checkmark-circled {
        position: absolute;
        top: 2px;
        right: 5px;
    }
.nice-box .p-1{
        font-size: 18px;
        text-align: center;
        background:#fff;
    }

.col-md-4{
    	max-width: 50%;
    }

.template-item{
    	background: url('/uploads/template_img/bj.png') no-repeat;
    	height:500px;
    	background-size:100% 100%;
}

.ivu-prev{
	width:180px;
 	margin-right:30px;
 	height:40px;
}
.ivu-prevs:hover{
 	background:#e1e1e1;
 	border:#e1e1e1;
 	color:#333;
 }
  .ivu-select-selection .ivu-select-arrow:nth-of-type(1){
 	    display: inline-block;
 }
 .ivu-position{
     position: absolute;
    left: 310px;
    bottom: 0px;
 }
 .ivu-modal-confirm-body{
	padding-left: 0;
}

</style>
<link rel="stylesheet" href="{$domainStatic}/{$assets}/admin/css/jquery.bigcolorpicker.css" type="text/css" />
{/block}

{block name="main"}
<main class="nicemip-container-body">
    <div class="row">
            <section class="col-lg-8">
                <div class="nice-box">
                <div class="nice-box-heading">
                	<h3 :class="setting_bu">1.站点设置</h3> <h3 class="setting_bu"> <img src="{$domainStatic}/{$assets}/admin/images/ar.png" /> </h3>
                    <h3 :class="setting_bu1">2.选择模板</h3> <h3 class="setting_bu"> <img src="{$domainStatic}/{$assets}/admin/images/ar.png" /> </h3>
                    <h3 :class="setting_bu2">3.模板设置</h3> <h3 class="setting_bu"> <img src="{$domainStatic}/{$assets}/admin/images/ar.png" /> </h3>
                    <h3 :class="setting_bu3">4.采集设置</h3> <h3 class="setting_bu"> <img src="{$domainStatic}/{$assets}/admin/images/ar.png" /> </h3>
                    <h3 :class="setting_bu4">5.域名绑定</h3> 
                </div>
                    
                </div>
                <div class="nice-box" >
                	 <!-- 站点设置start-->
                	<div  class="setting_1" v-show="setting_1_show">
               			<section class="nice-box-heading">
					        <h3>1、站点设置</h3>
					    </section>
					    <section class="nice-box-body">
					        <div class="row">
					            <div class="col-md-6">
					                <i-form label-position="top">
					                    <Form-item label="原网站域名">
					                        <i-input v-model="setting.domain" placeholder="www.nicemip.com" ref="domain" v-focus>
					                        <i-select v-model="setting.httpType" slot="prepend" style="width: 80px">
					                            <i-option value="http://">http://</i-option>
					                            <i-option value="https://">https://</i-option>
					                        </i-select>
					                        </i-input>
					                    </Form-item>
					                    <Form-item label="网站名称">
					                        <i-input v-model="setting.siteName"></i-input>
					                    </Form-item>
					                </i-form>
					            </div>
					        </div>
					    </section>

					    

					     <p style="line-height:70px; margin-left:30px;"><button type="button" class=" ivu-btn ivu-btn-primary ivu-prev"  @click="NextSetting"><span>下一步</span></button></p>
					 </div>
					 <!-- 站点设置end-->


                <!-- 选择模板start-->
					<div  class="setting_1" v-show="setting_2_show"> 
						<section class="nice-box-heading">
					        <h3>2、选择模板</h3>
					    </section>
						<main class="nicemip-container-body" style="height: calc(100% - 50px)">
						    <div class="row">
						        <div class="col-md-4" v-for='item in templateList'>
						            <section class="nice-box">
						                <section class="nice-box-body template-item">
						                    <Icon type="checkmark-circled" v-if='item.status' size='26' color='#00aaee'></Icon>
						                    <img :src="item.info.thumbnail" @click='chooseTemplate(item.fileName)'/>
						                    
						                </section>
						                <h4 class="p-1">{{item.info.name}}</h4>
						            </section>
						        </div>
						    </div>
						</main>
						<p style="line-height:70px; margin-left:30px;"> 
							<button type="button" class=" ivu-btn ivu-prev ivu-prevs "  @click="PrevTpSelect"><span>上一步</span></button> 
							<button type="button" class=" ivu-btn ivu-btn-primary ivu-prev"  @click="NextTpSelect"><span>下一步</span></button>

						</p>
					</div>
				<!-- 选择模板end-->
				<!-- 模板设置start-->
					<div  class="setting_1" v-show="setting_3_show"> 
						
						<section class="nice-box-heading">
					        <h3>3、模板设置</h3>
					    </section>
					    <section class="nice-box-body">
					        <div class="row">
					            <div class="col-md-6">
					                <i-form label-position="top">
					                    
					                    <Form-item label="主题颜色">
					                         <input   type="hidden" v-model="setting.siteColor" class="ivu-input"  style="width: 100px;" name="siteColor"   />
					                        <input  id="color_b" type="bottun" readonly class="ivu-input" v-bind:style="[baseStyles]"/>
					                      
					                    </Form-item>
					                    <Form-item label="网站Logo">
					                    	<img  :src="imgLogo" style="width:52px; margin-right:15px;" v-show="imgl">
					                    	<input type="file" name="fileLogo" class="form-control"  @change="getFile($event,'logo')" style="display: none;">
					                    	<button v-show="addpL" type="button" class=" ivu-btn ivu-btn-primary ivu-btn-circle" @click='addPic($event,"logo")'>
										        <span>添加图片 </span>
										    </button><font style="color:red;margin-left:15px;">(logo尺寸 52*52 推荐)</font>
										    <img v-show="addhL" src="{$domainStatic}/{$assets}/admin/images/0H1232460-0.jpg" />
					                    </Form-item>
					                    <Form-item label="Banner图">
					                    	 <img v-for="site in imgList" :src="site" style="width:180px; margin-right:15px;">
					                    	<input type="file" name="fileBanner" class="form-control" multiple  @change="getFile($event,'banner')" style="display: none;">
					                    	<button v-show="addpI" type="button" class="ivu-btn ivu-btn-primary ivu-btn-circle" @click='addPic($event,"banner")'>
										        <span>添加图片</span>
										    </button>
										    <img v-show="addhI" src="{$domainStatic}/{$assets}/admin/images/0H1232460-0.jpg" />
					                    </Form-item>
					                   
					                </i-form>
					            </div>
					        </div>
					    </section>	

					    

					    <p style="line-height:70px; margin-left:30px;">
					    	<button type="button" class=" ivu-btn ivu-prev ivu-prevs"  @click="PrevTpSetting"><span>上一步</span></button> 
					    	<button type="button" class=" ivu-btn ivu-btn-primary ivu-prev"  @click="NextTpSetting"><span>下一步</span></button> 
					    </p>

					</div>
				<!-- 模板设置end-->
				<!-- 采集设置start-->
					<div  class="setting_1" v-show="setting_4_show"> 
						<section class="nice-box-heading">
					        <h3>4、采集设置</h3>
					    </section>
						<main class="nicemip-container-body" style="height: calc(100% - 50px)">
						   
					    
					    <i-form label-position="top">
					        <section class="nice-box" id="step1">
					        <section class="nice-box-heading"><h3>1 填写迁入点</h3></section>
					            <div class="nice-box-body">
					                <div class="row">
					                    <div class="col-md-6">
					                        <Form-Item label="请填写迁入内容所在的列表页">
					                            <i-input v-model="res.url" v-on:keyup.enter="step2" placeholder="http://">
					                                <i-Button slot="append" @click="doStep1">抓取分析</i-Button>
					                            </i-input>
					                        </Form-Item>
					                        <Form-Item v-if="res1.status">
					                            <div :style="res1.tips_style" v-html="res1.tips"></div>
					                        </Form-Item>
					                    </div>
					                    <div class="col-md-6">
					                            <Form-Item label="备注说明：">填写的地址最好是某个类目下的列表页，迁入数据后无需再调整文章分类。</Form-Item>
					        
					                    </div>
					                </div>
					            </div>
					        </section>
					        <section class="nice-box" v-if="res2.status" id="step2">
				            <section class="nice-box-heading"><h3>2.1 确认迁入内容</h3></section>
				            <div class="nice-box-body">
				                <div class="row">
				                    <div class="col-md-12">
				                        <Form-Item label="以下哪些是需要迁入的内容？">
				                            <div class="url-group-box">
				                                <div :style="res2.list_group_style">
				                                    <div class="url-group list-group" v-for="(group, index) in res.data.groups" :id="'list_group_' + index">
				                                        <input type="checkbox" :value="index" v-model="res.list_keys">
				                                        <ul>
				                                            <li v-for="item in group.result"><a target="blank" :href="item.url" :title="item.text">{{item.text}}</a></li>
				                                        </ul>
				                                    </div>
				                                </div>
				                            </div>
				                        </Form-Item>
				                    
				                        <button type="button" class="ivu-btn ivu-btn-primary ivu-btn-circle" @click="step2_2">
				                            <span>确认</span>
				                        </button>
				                    </div>
				                </div>
				            </div>
				        </section>
				        <section class="nice-box" v-if="res2.status == 2" id="step2_2">
				            <section class="nice-box-heading"><h3>2.2 确认分页页码</h3></section>
				            <div class="nice-box-body">
				                <div class="row">
				                    <div class="col-md-12">
				                        <Form-Item label="以下哪组是分页页码？" v-if="res.data.groups2">
				                            <div class="url-group-box">
				                                <div :style="res2.page_group_style">
				                                    <div class="url-group page-group" v-for="(group, index) in res.data.groups2" :id="'page_group_' + index">
				                                        <input type="radio" :value="index" v-model="res.page_key">
				                                        <ul>
				                                            <li v-for="item in group.result"><a target="blank" :href="item.url" :title="item.text">{{item.text}}</a></li>
				                                        </ul>
				                                    </div>
				                                </div>
				                            </div>
				                        </Form-Item>
				                        <Form-Item v-else>
				                            <div style="color:gray">无分组链接可选</div>
				                        </Form-Item>
				                        
				                        <button type="button" class="ivu-btn ivu-btn-primary ivu-btn-circle" @click="step3">
				                            <span>{{res2.btn2_text}}</span>
				                        </button>
				                    </div>
				                </div>
				            </div>
				        </section>
				        <section class="nice-box" v-if="res3.status" id="step3">
			            <section class="nice-box-heading"><h3>3 预览迁入数据</h3></section>
			            <div class="nice-box-body">
			                <div class="row">
			                    <div class="col-md-12">
			                        <Form-Item label="预览智能提取的内容">
			                            <select v-model="res3.view_page_selected" @change="viewPage">
			                                <option v-for="(option,index) in res.list_links" :value="index">
			                                  {{option.text}}
			                                </option>
			                            </select>
			                        </Form-Item>
			                        
			                        <Form-Item label="抓取的页面内容：">
			                            <div class="view-page-content" v-html="res3.view_page_content"></div>
			                        </Form-Item>
			                        
			                        <button type="button" class="ivu-btn ivu-btn-primary ivu-btn-circle" @click="step4">
			                            <span>跳过</span>
			                        </button>
			                    </div>
			                </div>
			            </div>
			        </section>
			        <section class="nice-box" v-if="res3.status"  id="step4">
			            <section class="nice-box-heading"><h3>4 设置分类，开始执行</h3></section>
			            <div class="nice-box-body">
			                <div class="row">
			                    <div class="col-md-12">
			                        <Form-Item label="请选择内容所属的分类">
			                            <Cascader :data="res3.articleCategoryList" transfer v-model="res.cid"  style="width: 300px;"></Cascader>
			                        	<button type="button" class="ivu-btn ivu-btn-primary ivu-btn-circle ivu-position"  @click='newAdd' >
								            <span><Icon type="plus-round"></Icon> 添加分类</span>
								        </button>
			                        </Form-Item>
			                        
			                        <button type="button" class="ivu-btn ivu-btn-circle" @click="doStep4(0)">
			                            <span>保存</span>
			                        </button>
			                        <button type="button" class="ivu-btn ivu-btn-primary ivu-btn-circle" @click="doStep4(1)">
			                            <span>保存，并执行内容迁入</span>
			                        </button>
			                    </div>
			                </div>
			            </div>
			        </section>
					    </i-form>
						</main>
						<p style="line-height:70px; margin-left:30px;">
							<button type="button" class=" ivu-btn ivu-prev ivu-prevs"  @click="PrevAutocont"><span>上一步</span></button> 
							<button type="button" class=" ivu-btn ivu-btn-primary ivu-prev"  @click="NextAutocont"><span>下一步</span></button> 
						</p>
					</div>
				<!-- 采集设置end-->
				<!-- 域名绑定start-->
					<div  class="setting_1" v-show="setting_5_show"> 
						<section class="nice-box-heading">
					        <h3>5、域名绑定</h3>
					    </section>
						 <section class="nice-box-body">
					        <div class="row">
					            <div class="col-md-6">
					                <i-form label-position="top">
					            
					                    <Form-item label="域名绑定">
					                        <i-input v-model="setting.mipDomain"></i-input>
					                    </Form-item>
					                    <p style="color:#F00;">请填写MIP化站点所使用的域名,请将该域名使用CNAME解析到如下地址 nicemip.com</p>
					                </i-form>
					            </div>
					        </div>
					    </section>
						<p style="line-height:70px; margin-left:30px;">
							<button type="button" class=" ivu-btn ivu-btn-primary ivu-prev"  @click="PrevOne"><span>上一步</span></button> 
							<button type="button" class=" ivu-btn ivu-btn-primary ivu-prev" @click="SettingOk"><span>完成</span></button> 
							</p>
					</div>
				<!-- 域名绑定end-->

                </div>
                

            <!--设置部分end-->
            </section>
            <section class="col-lg-4">
                <div class="nice-box">
                    <div class="nice-box-heading"><h3 class="left">功能介绍</h3></div>
                    <div class="nice-box-body">
                        <ul class="list-unstyled">
                            <li class="list-time line" v-for="item in functionList" ><a :href="item.url" target="_blank" v-html='item.title'></a></li>
                        </ul>
                    </div>
                </div>
            </section>

          </div>
          <!--弹出提示框-->

			    <Modal
			        v-model="modal1"
			        title="温馨提示"
			        @on-ok="ok"
			        @on-cancel="cancel">
			        <p>{{vis_value}}</p>
			    </Modal>
			    
			    <Modal  v-model="category.dialogCategory" size="large" v-cloak width='1000' :mask-closable="false">
        <i-form :model="category" :rules="category.categoryRules" ref="category" :label-width="80">
            <Tabs :animated='false' v-model="itemTabsValue">
                <Tab-Pane label="基础信息" name='default'>
                    <Form-Item label="分类" prop="title">
                        <i-Select v-model="category.pid" transfer style="width:200px" :disabled='category.categoryStatus && category.pid == 0 && category.isChild'>
                            <i-Option v-for="item in category.categoryList" :disabled="item.disabled" :value="item.id" :key="item.id">{{ item.name }}</i-Option>
                        </i-Select>
                    </Form-Item> 
                    <Form-Item label="分类名称" prop="name">
                        <i-input v-model="category.name" placeholder="例：网站优化"></i-input>
                    </Form-Item>
                    <Form-Item label="URL别名" prop="url_name">
                        <i-input placeholder="例：seo" v-model="category.url_name"><i-Button slot="append" class="tags-btn" @click='getPinyin'>获取拼音</i-Button></i-input>
                    </Form-Item>
                    <form-item label="自定义标题">
                        <i-input placeholder="例：自定义分类标题" v-model="category.seo_title"></i-input>
                    </Form-Item>
                    <Form-Item label="关键词">
                        <i-input type="textarea" v-model="category.keywords" placeholder="例：SEO,SEO优化,搜索引擎优化,网站排名"></i-input>
                    </Form-Item>
                    <Form-Item label="描述">
                        <i-input type="textarea" v-model="category.description" placeholder="请输入description描述信息"></i-input>
                    </Form-Item>
                </Tab-Pane>
               
            </Tabs>
            </i-form>
            <div slot="footer" class="dialog-footer">
                <i-button >取 消</i-button>
                <i-button type="primary" @click="categoryPost('category',category)">确 定</i-button>
            </div>
        </Modal>

</main>
{/block}
    
{block name="javascript"}
{__block__}

<script src="{$domainStatic}/{$assets}/admin/js/jquery.bigcolorpicker.js"></script>

<!-- import iView -->


<script>

	//Vue.use(VuejsDialog.default)
    new Vue({

        el: '#app',
        data: {
        	imgl:false,
            functionList: [
            	{
	            	'url':'#',
	            	'title':'ABC入门'
            	},
            	{
            		'url':'#',
            		'title': '平台接入篇'
            	},
            	{
            		'url':'#',
            		'title': '内容运营篇'
            	},
            	{
            		'url':'#',
            		'title': '智能设置篇'
            	},
            	{
            		'url':'#',
            		'title': '模板管理篇'
            	}
            ],
            setting: [],
            modal1: false,
            vis_value:'',
            /***选择模板****/
            templateList: [],//选择模板
            siteInfo: '',

            setting_1_show:true,
            setting_2_show:false,
            setting_3_show:false,
            setting_4_show:false,
            setting_5_show:false,
            
            setting_bu:'setting_bu active',
            setting_bu1:'setting_bu ',
            setting_bu2:'setting_bu ',
            setting_bu3:'setting_bu',
            setting_bu4:'setting_bu',

            /***模板设置****/
            baseStyles:{
 					width: '25px',
 				    height: '25px',
 				    padding: '0px',
 				    border: '0px',
 				    cursor: 'pointer',
 				    background:'#2796ea',
             },
            imgList:'',
            imgLogo:'',
            addpI:true,
 			addhI:false,
 			addpL:true,
 			addhL:false,
 			codeDemo: '<mip-stats-baidu token="02890d4a309827eb62bc3335b2b28f7f"></mip-stats-baidu>',

 			/*****数据采集*******/

 			res: {
                url: '',
                cid: 0,
                list_keys: [],
                page_key: '',
                list_links: [],
                page_links: [],
                data: {},
            },
            res1: {
                status : false,
                tips_style:'color:gray',
                tips: '请求列表页，链接提取中...'
            },
            res2: {
                status : false,
                list_group_style: '',
                page_group_style: '',
                btn2_text: '确定',
            },
            res3: {
                status : false,
                view_page_selected: '',
                view_page_content: '页面内容提取分析中...',
                articleCategoryList: [],
            },
            category: {
                categoryList: [],
                dialogCategory: false,
                dialogCategoryTitle: '',
                isChild: false,
                id: '',
                pid: 0,
                name: '',
                url_name: '',
                seo_title: '',
                description: '',
                keywords: '',
                template: '{$itemUrl}.html',
                detail_template: '{$itemUrl}Detail.html',
                category_url: '/{$itemUrl}/<url_name>/',
                category_page_url: '<category_url>index_<page>.html',
                detail_url: '/{$itemUrl}/<id>.html',
                categoryRules: {
                    name: [{
                        required: true,
                        message: '请输入名称',
                        trigger: 'blur'
                    }],
                    url_name: [{
                        required: true,
                        message: '请输入别名',
                        trigger: 'blur'
                    }],
                },
                categoryStatus: false,
                categoryListEdit: [],
            },
            itemTabsValue: 'default',
            tempCategoryList: [],


		    
        },

        watch: {
        	siteChangeStatus() {
                this.getSettingData();
            },
        },
        mounted() {
            this.getSettingData();
            _this = this;
            this.getCategoryList();
        },
       
 
        methods: {

           //站点设置下一步
           NextSetting:function(){
           		this.domain = this.setting.domain;
           		this.siteName = this.setting.siteName;
           		this.httpType = this.setting.httpType;
           		this.setting = {
           			'domain' : this.setting.domain,
           			'siteName' : this.setting.siteName,
           			'httpType' : this.setting.httpType,
           		}

           		if(this.domain == "" || this.domain == undefined){
           			this.vis_value = '请填写原网站域名';
           			this.modal1 = true;
           			return false;
           		}else{
           			var _httpType = this.setting.httpType;
           			if(_httpType == undefined){
           				this.vis_value = '请选择http/https 协议';
           				this.modal1 = true;
           				return false;
           			}
           			var reg=/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
           			if(!reg.test(this.httpType+this.domain)){
           				this.vis_value = '请填写正确的域名';
           				this.modal1 = true;
           				return false;
           			}
           			var _this = this;
	                this.$nicemip.ajax('{$domain}/setting/ApiAdminSetting/settingEdit', {
	                    setting: JSON.stringify(this.setting),
	                }).then(function(res) {
	                    if(res.code == 1) {
	                    	/* _this.$Modal.confirm({
		                    title: '消息提示',
		                    content: '<p>网站域名设置成功 请点击确定下一步选择模板</p>',
		                    onOk: () => {
		                        _this.ShowArrSetting();
		                    }, 
		                    onCancel: () => {
		                        //
		                    } 
		                    
		                });*/
		                _this.ShowArrSetting();
	                        
	                    }
	                });
           			
           		}
           },
           //选择模板下一步
           NextTpSelect:function(){
           		/* this.$Modal.confirm({
		            title: '消息提示',
		            content: '<p>模板选择成功 请点击确定 设置属于你自己专有的模板吧！</p>',
			            onOk: () => {
			                this.ShowArrTpSelect();
			            }, 
			            onCancel: () => {
			                        //
			            }
			            
		        }); */
           		this.ShowArrTpSelect();
           },
           //模板设置下一步
           NextTpSetting:function(){
        	   var siteColor = this.setting.siteColor;
              	var siteLogo = this.setting.siteLogo;
              	var siteImg = this.setting.siteImg;
              		this.setting = {
              			'siteColor' : this.setting.siteColor,
              			'siteLogo' : this.setting.siteLogo,
              			'siteImg' : this.setting.siteImg,
              		}
              	if(siteColor == undefined){
              			this.$Modal.confirm({
   		                    title: '消息提示',
   		                    content: '<p>请设置主题颜色</p>',
   			                    onOk: () => {
   			                    	
   			                    }, 
   			                    onCancel: () => {
   			                       
   			                    }
   		            });
   		             return false;
              	}
              	
              	if(siteLogo == undefined){
              			this.$Modal.confirm({
   		                    title: '消息提示',
   		                    content: '<p>请上传logo</p>',
   			                    onOk: () => {
   			                    	
   			                    }, 
   			                    onCancel: () => {
   			                       
   			                    }
   		            });
   		            return false;
              	}
              	if(siteImg == undefined){
              			this.$Modal.confirm({
   		                    title: '消息提示',
   		                    content: '<p>请上传banner图</p>',
   			                    onOk: () => {
   			                    	
   			                    }, 
   			                    onCancel: () => {
   			                        
   			                    }
   		            });
   		            return false;
              	}
           		//提交设置
           		var _this = this;
	            this.$nicemip.ajax('{$domain}/setting/ApiAdminSetting/settingEdit', {
	                    setting: JSON.stringify(this.setting),
	                }).then(function(res) {
	                    if(res.code == 1) {
	                    	/* _this.$Modal.confirm({
		                    title: '消息提示',
		                    content: '<p>网站模板设置成功 请点击确定采集更多精彩内容！！！</p>',
			                    onOk: () => {
			                        _this.ShowArrTpSetting();
			                    }, 
			                    onCancel: () => {
			                        //
			                    }
		                	}); */
	                    	_this.ShowArrTpSetting();
	                        
	                    }
	            });
           },
           //采集设置下一步
           NextAutocont:function(){

           			this.ShowArrAutocont();
           },
           //上一步
           PrevOne:function(){
           		this.ShowArrTpSetting();
           },
           PrevAutocont:function(){
           		this.ShowArrTpSelect();
           },
           PrevTpSetting:function(){
           		this.ShowArrSetting();
           },
           PrevTpSelect:function(){

           		this.ShowArr();
           },
           //显示
           ShowArr:function(){
           			this.setting_bu  = 'setting_bu active';
		            this.setting_bu1 = 'setting_bu ';
		            this.setting_bu2 = 'setting_bu';
		            this.setting_bu3 = 'setting_bu';
		            this.setting_bu4 = 'setting_bu';
		            
		            this.setting_1_show = true;
		            this.setting_2_show = false;
		            this.setting_3_show = false;
		            this.setting_4_show = false;
		            this.setting_5_show = false;
           },
           ShowArrSetting:function(){
           			this.setting_bu  = 'setting_bu ';
		            this.setting_bu1 = 'setting_bu active';
		            this.setting_bu2 = 'setting_bu';
		            this.setting_bu3 = 'setting_bu';
		            this.setting_bu4 = 'setting_bu';
		            
		            this.setting_1_show = false;
		            this.setting_2_show = true;
		            this.setting_3_show = false;
		            this.setting_4_show = false;
		            this.setting_5_show = false;
           },
           ShowArrTpSelect:function(){
           			this.setting_bu  = 'setting_bu ';
		            this.setting_bu1 = 'setting_bu ';
		            this.setting_bu2 = 'setting_bu active';
		            this.setting_bu3 = 'setting_bu';
		            this.setting_bu4 = 'setting_bu';
		            
		            this.setting_1_show = false;
		            this.setting_2_show = false;
		            this.setting_3_show = true;
		            this.setting_4_show = false;
		            this.setting_5_show = false;
           },
           ShowArrTpSetting:function(){
           			this.setting_bu  = 'setting_bu ';
		            this.setting_bu1 = 'setting_bu ';
		            this.setting_bu2 = 'setting_bu ';
		            this.setting_bu3 = 'setting_bu active';
		            this.setting_bu4 = 'setting_bu';
		            
		            this.setting_1_show = false;
		            this.setting_2_show = false;
		            this.setting_3_show = false;
		            this.setting_4_show = true;
		            this.setting_5_show = false;
           },
           ShowArrAutocont:function(){
           			this.setting_bu  = 'setting_bu ';
		            this.setting_bu1 = 'setting_bu ';
		            this.setting_bu2 = 'setting_bu';
		            this.setting_bu3 = 'setting_bu';
		            this.setting_bu4 = 'setting_bu active';
		            
		            this.setting_1_show = false;
		            this.setting_2_show = false;
		            this.setting_3_show = false;
		            this.setting_4_show = false;
		            this.setting_5_show = true;
           },
           /*******提示框*******/
            ok () {
                this.$refs.domain.focus();
            },
            cancel () {
                this.$refs.domain.focus();
            },

            /******选择模板start**************/
            getTemplateList() {
                var _this = this;
                this.$nicemip.ajax('{$domain}/setting/ApiAdminTemplate/templateList', {
                }).then(function(res) {
                    if(res.code == 1) {
                        var templateList = res.data;
                        for (var i = 0; i < templateList.length; i++) {
                            if (templateList[i].fileName == _this.siteInfo.template) {
                                templateList[i].status = true;
                            } else {
                                templateList[i].status = false;
                            }
                              
                        }
                        _this.templateList = templateList;
                    }
                });
            },
            getSettingData() {
                var _this = this;
                this.loading = true;
                this.$nicemip.ajax('{$domain}/setting/ApiAdminSetting/settingSelect', {
                    
                }).then(function(res) {
                    _this.loading = false;
                    if(res.code == 1) {
                        _this.siteInfo = res.data;
                        _this.getTemplateList();
                    }
                });
            },
            chooseTemplate(val) {
                this.$Modal.confirm({
                    title: '消息提示',
                    content: '<p>确定切换成您选择的模板？</p>',
                    onOk: () => {
                        var _this = this;
                        this.$nicemip.ajax('{$domain}/setting/ApiAdminTemplate/templateSave', {
                            fileName: val,
                        }).then(function(res) {
                            if(res.code == 1) {
                                _this.$Message.success('设置成功');
                                _this.getSettingData();
                            }
                        });
                    }, 
                    onCancel: () => {
                        //
                    }
                });
            },
             /******选择模板end**************/

             /****模板设置start********/
             getFile: function (event,type) {
            	var that = this;
            	var leng=event.target.files.length;
            	let form = new FormData();
            	var fileList = [];
            	for(var i=0;i<leng;i++){
            		fileList.push(event.target.files[i]);
            	}
            	fileList.forEach(function (file) {
                	form.append('files[]', file, file.name);
            	})
  				//隐藏按钮  现在加载
  				if(type == 'logo'){
  					that.addpL = false;
  					that.addhL = true;
  				}else{
  					that.addpI = false;
  					that.addhI = true;
  				}
  				
        		let config = { headers: { 'Content-Type': 'multipart/form-data' } };
        		this.$nicemip.ajax('{$domain}/setting/ApiAdminSetting/settingUpload', form, config ).then(function(res) {
        			
                    if(res.code == 1) {
                    	
  						if(type == 'logo'){
  							that.addpL = true;
  							that.addhL = false;
  							that.imgl  = true;
  							that.imgLogo = res.data.siteImgArr;
  							that.setting.siteLogo = res.data.file_name;  
  						}else{
  							that.addpI = true;
  							that.addhI = false;
  							that.imgList = res.data.siteImgArr;
  							that.setting.siteImg = res.data.file_name;  
  						}
                        

                    }
                });
	      	},

	      //多图上传
	      	addPic(e,type){
                e.preventDefault();
                if(type == 'logo'){
                	$('input[name=fileLogo]').trigger('click');
                }else{
                	$('input[name=fileBanner]').trigger('click');
                }     
                return false;
            },
             /****模板设置end**********/

             /****数据采start*******/
             doStep1: function () {
                this.res1.status = 'doing';
                this.list_keys  = [];
                this.page_key   = '';
                this.list_links = [];
                this.page_links = [];
                this.data       = {};
                this.res2.status = false;
                this.res3.status = false;
                
                this.res1.tips_style = 'color:gray';
                this.res1.tips = '请求列表页，链接提取分析中...';
                this.$nicemip.ajax('{$domain}/{$Think.config.admin}/ApiAdminACI/autoContentIncomeStep1',{
                    url: this.res.url,
                }).then(function (res) {
                    _this.res.data = res.data;
                    _this.res.list_keys = [];
                    _this.res.page_key  = '';
                    
                    if (res.code == 1) {
                        _this.res.url = res.data.url;
                        if (res.data.count > 0) {
                            _this.res1.status = 'ok';
                            _this.res1.tips_style = 'color:green';
                            _this.res1.tips = '从列表页中共提取了 <b>'+res.data.count+'</b> 条链接';
                        } else {
                            _this.res1.status = 'fail';
                            _this.res1.tips_style = 'color:red';
                            _this.res1.tips = '列表页未识别到链接存在';
                        }
                        
                        for (var key in res.data.groups) {
                            for (var k in res.data.groups[key].type) {
                                if (res.data.groups[key].type[k] == 'list') {
                                    _this.res.list_keys.push(key);
                                } else if (_this.res.page_key === '' && res.data.groups[key].type[k] == 'page') {
                                    _this.res.page_key      = key;
                                }
                            }
                        }
                    } else {
                        _this.res1.status = 'fail';
                        _this.res1.tips_style = 'color:red';
                        _this.res1.tips = res.msg;
                    }
                    
                    if (_this.res1.status == 'ok') {
                        _this.res2.status = 'ok';
                        _this.res3.status = false;
                        _this.res2.list_group_style = 'width:'+(_this.res.data.groups.length * 260) + 'px';
                        
                        $('.list-group').show();
                        _this.scrollBottom('step2');
                    }
                });   
            },

            step2_2: function() {
                if (this.res.list_keys.length == 0) {
                    this.$Message.error('请确认列表链接');
                    return false;
                }
                this.res3.status = false;
                
                $('.list-group').hide();
                for (var k in this.res.list_keys) {
                    $('#list_group_' + this.res.list_keys[k]).show();
                }
                this.res.list_group_style = 'width:'+(this.res.list_keys.length * 260) + 'px';
                
                var list_keys   = [];
                for (var i in this.res.list_keys) {
                    list_keys.push(parseInt(this.res.list_keys[i]));
                }
                
                this.res.data.groups2    = null;
                for (var k in this.res.data.groups) {
                    if (-1 !== $.inArray(parseInt(k), list_keys)) {
                        continue;
                    }
                    if (this.res.data.groups2 === null) {
                        this.res.data.groups2 = {};
                        this.res.data.groups2_count = 1;
                    }
                    this.res.data.groups2[k] = this.res.data.groups[k];
                    this.res.data.groups2_count ++;
                }
                
                this.res2.status = 2;
                if (this.res.data.groups2 !== null) {
                    this.res2.page_group_style = 'width:'+(this.res.data.groups2_count * 260) + 'px';
                    if (this.res.page_key !== '') {
                        if (-1 !== $.inArray(this.res.page_key, list_keys)) {
                            this.res.page_key   = '';
                        }
                    }
                    
                    this.btn2_text = '确定';
                } else {
                    this.btn2_text = '跳过';
                }

                $('.page-group').show();
                this.scrollBottom('step2_2');
            },
            step3: function () {
                $('.page-group').hide();
                $('#page_group_' + this.res.page_key).show();
                this.res2.page_group_style = 'width:260px';
                
                this.res3.status = true;
                this.getArticleCategoryList();
                
                this.res.page_links = this.res.data.groups[this.res.page_key];
                this.res.list_links = [];
                for (var i in this.res.list_keys) {
                    if (this.res.list_links.length == 0) {
                        this.res.list_links = this.res.data.groups[this.res.list_keys[i]].result;
                    } else {
                        for (var key in this.res.data.groups[this.res.list_keys[i]].result) {
                            this.res.list_links.push(this.res.data.groups[this.res.list_keys[i]].result[key]);
                        }
                    }
                }
                
                for (var key in this.res.list_links) {
                    this.res3.view_page_selected = key;
                    this.viewPage();
                    break;
                }
                
                this.scrollBottom('step3');
            },
            viewPage: function () {
                if (this.res3.view_page_selected === '') {
                    this.$Message.error('请选择要预览的页面');
                    return false;
                }
                selected    = this.res.list_links[this.res3.view_page_selected];
                this.res3.view_page_content = '页面内容提取分析中...';
                this.$nicemip.ajax('{$domain}/{$Think.config.admin}/ApiAdminACI/autoContentIncomeStep3',{
                    url: /* this.res.data.domain +  */selected.url,
                    title: selected.text,
                }).then(function (res) {
                    _this.res3.status = true;
                    if (res.code == 1) {
                        _this.res3.view_page_content = res.data.content;
                    }
                });
            },
            getArticleCategoryList: function() {
                this.$nicemip.ajax('{$domain}/article/ApiAdminArticle/categoryList', {
                    
                }).then(function (res) {
                    if(res.code == 1) {
                        _this.res3.articleCategoryList = res.data.categoryList;
                    }
                });
            },
            step4: function () {
                this.scrollBottom('step4');
            },
            doStep4: function(need_exe) {
            	console.log(this.res.cid);
                if (!this.res.cid || !this.res.cid[0]) {
                    this.$Message.error('请选择分类');
                    return false;
                }
                
                var list_links  = [];
                for (var i in this.res.list_keys) {
                    list_links.push(this.res.data.groups[this.res.list_keys[i]].result);
                }
                
                this.$nicemip.ajax('{$domain}/{$Think.config.admin}/ApiAdminACI/autoContentIncomeStep4',{
                    need_exe: need_exe,
                    cid: this.res.cid[0],
                    url: this.res.url,
                    auto_rule: {
                        list_links: list_links,
                        page_links: [this.res.data.groups[this.res.page_key].result]
                    }
                }).then(function (res) {
                    if(res.code == 1) {
                        _this.$Message.success(res.msg);
                        setTimeout(function() {
                            window.location.href = '{$domain}/{$Think.config.admin}/addons/autocontentincome/AdminAutoContentIncome/autoContentIncome';
                        }, 500);
                    } else {
                        _this.$Message.error(res.msg);
                    }
                });
            },
            scrollBottom(hash) {
                setTimeout(function() {
                    window.location.hash    = '#'+hash;
                }, 400);
            },
          //采集添加分类
          getPinyin: function() {
                if (!this.category.name) {
                    this.$Message.error('请输入名称');
                    return false;
                }
                this.$nicemip.ajax('{$domain}/{$Think.config.admin}/ApiAdminMipPost/getPinyin', {
                    words: this.category.name,
                }).then(res => {
                    if(res.code == 1) {
                        this.category.url_name = res.data;
                    }
                });
            },
            newAdd: function() {
                this.category.categoryStatus = false;
                this.category.isChild = false;
                this.itemTabsValue = 'default';
                this.category.pid = 0,
                this.category.name = '';
                this.category.url_name = '';
                this.category.seo_title = '';
                this.category.template = '{$itemUrl}.html';
                this.category.detail_template = '{$itemUrl}Detail.html';
                this.category.category_url = '/{$itemUrl}/<url_name>/';
                this.category.category_page_url = '<category_url>index_<page>.html';
                this.category.detail_url = '/{$itemUrl}/<id>.html';
                this.category.description = '';
                this.category.keywords = '';
                this.category.id = '';
                this.category.dialogCategory = true;
                this.category.dialogCategoryTitle = '添加分类';
            },
            categoryPost(val, param) {
            	if (!this.category.url_name) {
                    this.$Message.error('请输入基础信息中的必填项');
                    return false;
            	}
            	if (!this.category.name) {
                    this.$Message.error('请输入基础信息中的必填项');
                    return false;
            	}
                this.$refs[val].validate((valid) => {
                    if(valid) {
                        var parent=/^[a-zA-Z0-9_-]+$/;
                        if (!parent.test(this.category.url_name)) {
                            this.$Message.error('别名输入值不支持');
                            return false;
                        }
                        if(this.category.categoryStatus == false) {
                            this.$nicemip.ajax('{$domain}/article/ApiAdminArticle/categoryAdd', {
                                pid: this.category.pid,
                                name: this.category.name,
                                url_name: this.category.url_name,
                                seo_title: this.category.seo_title,
                                template: this.category.template,
                                detail_template: this.category.detail_template,
                                category_url: this.category.category_url,
                                category_page_url: this.category.category_page_url,
                                detail_url: this.category.detail_url,
                                description: this.category.description,
                                keywords: this.category.keywords,
                            }).then(res => {
                                if(res.code == 1) {
                                    this.category.dialogCategory = false;
                                    this.$Message.success(res.msg);
                                    this.getArticleCategoryList();
                                }
                            });
                        }
                    }
                });
            },
            getCategoryList: function() {
                this.$nicemip.ajax('{$domain}/article/ApiAdminArticle/categoryList', {
                }).then(res => {
                    if(res.code == 1) {
                        var categoryList = res.data.categoryList;
                        for (var i = 0; i < categoryList.length; i++) {
                            categoryList[i].isOpen = false;
                        }
                        for (var i = 0; i < categoryList.length; i++) {
                            if (this.tempCategoryList.length) {
                                for (var j = 0; j < this.tempCategoryList.length; j++) {
                                	   if (this.tempCategoryList[j].id == categoryList[i].id) {
                                        categoryList[i].isOpen = this.tempCategoryList[j].isOpen;
                                	   }
                                }
                            }
                        }
                        this.categoryList = categoryList;
                        
                        var tempCategoryList = [{id:0,pid: 0,name:'顶层分类'}];
                        for (var i = 0; i < categoryList.length; i++) {
                            categoryList[i].disabled = false;
                            if (categoryList[i].pid == 0) {
                                tempCategoryList.push(categoryList[i]);
                            }
                        }
                        this.category.categoryList = tempCategoryList;
                        
                       
                        
                    }
                });
            },
            /****数据采集end********/
          //完成设置
            SettingOk:function(){
            	_this = this;
            	var mipDomain = this.setting.mipDomain;
            	if(mipDomain == '' || mipDomain == undefined){
            		_this.$Modal.confirm({
                    title: '消息提示',
                    content: '<p>请输入mip化后网站显示域名！！！</p>',
	                    onOk: () => {
	                       //
	                    }, 
	                    onCancel: () => {
	                        //
	                    }
                	});
            	}else{
            		this.$nicemip.ajax('{$domain}/setting/ApiAdminSetting/settingEdit', {
                        setting: JSON.stringify(this.setting),
                    }).then(function(res) {
                        if(res.code == 1) {
                        	_this.Ping(mipDomain); 
                        }
                	});
            	}
            	
            	
            	
            },
            //模拟ping功能
            Ping:function(ip){
            	_this = this;
            	var img = new Image();
			    var start = new Date().getTime();
			    var flag = false;
			    var isCloseWifi = true;
			    var hasFinish = false;

			    img.onload = function() {
			        if ( !hasFinish ) {
			            flag = true;
			            hasFinish = true;
			            console.log('Ping ' + ip + ' success1. ');
			            window.open('{$webUrl}');
			            window.location.href = '{$domain}/{$Think.config.admin}';
			        }
			    };

			    img.onerror = function() {
			        if ( !hasFinish ) {
			            if ( !isCloseWifi ) {
			                flag = true;
			                console.log('Ping ' + ip + ' success2. ');
			                 _this.$Modal.confirm({
			                    title: '消息提示',
			                    content: '<p>恭喜您设置成功,如何您需要修改  请前往网站管理的站点设置里面进行修改</p>',
			                    onOk: () => {
			                        window.location.href = '{$domain}/{$Think.config.admin}';
			               			window.open('http://'+ip);
			                    }, 
			                    onCancel: () => {
			                        window.location.href = '{$domain}/{$Think.config.admin}';
			               			window.open('http://'+ip);
			                    }
			                     });   
			            } else {
			                console.log('network is not working!');
			            }
			            hasFinish = true;
			        }
			    };


			    setTimeout(function(){
			        isCloseWifi = false;
			        console.log('network is working, start ping...');
			    },2);

			    img.src = 'http://' + ip + '/' + start;
			    var timer = setTimeout(function() {
			        if ( !flag ) {
			            hasFinish = true;
			            flag = false ;
			            console.log('Ping ' + ip + ' fail. ');
			            _this.$Modal.confirm({
	                    title: '消息提示',
	                    content: '<p>您的域名还没有解析成功，请将该域名使用cna的方式解析到如下地址 nicemip.com/test  然后进入到网站管理进行域名绑定</p>',
	                    onOk: () => {
	                        window.location.href = '{$domain}/{$Think.config.admin}';
	                    }, 
	                    onCancel: () => {
	                        //
	                    }
	                });
			        }
			    }, 1500);	
            },
            
            
           
         }

    })
  </script>

 <script type="text/javascript">
	$(function(){
		$("#color_b").bigColorpicker(function(el,color){
			 $("input[name='siteColor']").val(color);
			 $("#color_b").css('background',color);
	                //触发一下该input的input事件
	         $("input[name='siteColor']")[0].dispatchEvent(new Event('input'))
		});
	})
	

    </script>

{/block}